﻿validateUser(SAPUserStore);//validar login de usuario
//---------------------------------------------------
UsuarioWebStore.load();

var listaDetDocPanelTBT = new Ext.Toolbar({
	title: 'Detalle Documento',
	items: [
	{
		xtype: 'button',
		ui: 'back',
		text: 'Volver',
		iconCls: 'reply',
		iconMask: true,
		handler: function()
		{
			window.open("listarDocumentos.html","_self");
		}
	}]
});

var listaDetDocPanelTBB = new Ext.Toolbar({
	dock: 'bottom',
	items: [
	{
		xtype: 'toolbar',
		dock: 'bottom',
		ui: 'light',
		defaults: {
			iconMask: true,
			width: 140,
		},
		items: [{
			xtype: 'spacer'
		},
		{
			xtype: 'button',
			iconCls: 'compose',
			text: 'Modificar',
			handler: function()
			{
				window.open("documento.html","_self");
			}
		},
		{
			xtype: 'spacer'
		},
		{
			xtype: 'button',
			iconCls: 'search',
			text: 'Visualizar',
			handler: function()
			{
				window.open("documento.html","_self");
			}
		},
		{
			xtype: 'spacer'
		},
		{
			xtype: 'button',
			iconCls: 'refresh',
			text: 'Flujo',
			handler: function()
			{
				window.open("flujo.html","_self");
			}
		},
		{
			xtype: 'spacer'
		},
		{
			xtype: 'button',
			iconCls: 'action',
			text: 'Imprimir',
			handler: function()
			{
				Ext.Msg.alert('', 'Se imprimió documento', function(res)
				{
					window.open("menu.html","_self");
				}, this);        			
			}
		},
		{
			xtype: 'spacer'
		}]
	}]
});

var listaDetDoc = new Ext.List({
	id: 'listaDetDoc',
	store: pedidoStore,
	itemTpl:
	'<div class="materialItem">'+
	'<div class="doc-img"><img src="resources/images/detdoc_img.png" width="40" height="40"></div>'+
        '<div class="list-deti">'+
            '<span class="list-izq">{Posicion} - {CodMaterialCorto}</span>'+
			'<br />'+
			'{DescMaterial}'+
        '</div>'+
		'<div class="list-detc">'+
            '<span class="list-izq">{Cantidad}&nbsp;{UnidadMedida}&nbsp;&nbsp;&nbsp;F. Reparto:&nbsp;{FechaEntregaString}</span>'+
			'<br />'+
			'{CantidadConf}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F. Conf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;{FConf}'+
        '</div>'+
        '<div class="list-detd">'+
            '<span>{Total}</span>'+ 
			'<br />'+
			'{MotivoRechazo}'+
        '</div>'+
    '</div>',
	listeners: {
		'render': function (thisComponent) {
			thisComponent.getStore().load();
			if(detalleMaterialStore.last()){
				var doc = pedidoStore.last().data.id;
				thisComponent.getStore().clearFilter();
				thisComponent.getStore().filter('idDoc',doc);
			}
		}
	}
});

var listaDetDocPanel = new Ext.form.FormPanel({
	id: 'listaDetDocPanel',
	dockedItems: [listaDetDocPanelTBT,listaDetDocPanelTBB],
	items: [listaDetDoc]
});